import { eventList } from "../../../api/event"
const app = getApp();
Page({
    data: {
        navData: {
            title: '事件处理',
            level:2,
        },
        navMargin: app.globalData.navHeight + app.globalData.navTop,
        navIndex: 1,
        selectEventStatus: "1,2,3",
        list: [
            {
                type: '违停',
                status: '已处理',
                text: '违停',
                time: '2022-09-27 10:50',
            },
            {
                type: '裂缝一体机',
                status: '未处理',
                text: '裂缝一体机',
                time: '2022-09-27 10:50',
            }
        ]
    },
    onLoad(options) {

    },
    onShow() {
        this.getEventList();
    },
    onReady() {

    },
    //获取事件列表
    async getEventList() {
        let _this = this.data;
        let res = await eventList({ selectEventStatus: _this.selectEventStatus });
        let { code,rows } = res.data;
        if(code===200){
            this.setData({
                list:rows,
            });
        };
        console.log(res, '事件列表');
    },
    //切换栏事件
    navEvent(e) {
        let index = e.currentTarget.dataset.index;
        let status = "";
        if (index === 1) {
            status = "1,2,3";
        } else if (index === 2) {
            status = "1,2";
        } else if (index === 3) {
            status = "3";
        };
        this.setData({
            navIndex: index,
            selectEventStatus:status,
        });
        this.getEventList();
    },
    //列表详情
    listClick(e) {
        const item = e.currentTarget.dataset.item;
        wx.navigateTo({
            url: '/pagesXiaoXi/pages/eventDetail/index?item='+encodeURIComponent(JSON.stringify(item)),
        })
    },



    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})